<?php

namespace User\Form;

use Zend\Form\Form;
use Zend\Form\Element;
use Zend\Form\Element\Csrf;

class Base extends Form
{
    public function __construct() {

        parent::__construct();

        $this->add(array(
            'name' => 'username',
            'options' => array(
                'label' => 'Username',
            ),
            'attributes' => array(
                'type' => 'text',
                'class' => 'form-control col-xs-12',
                'placeholder' => 'Username',
            ),
        ));

        $this->add(array(
            'name' => 'email',
            'options' => array(
                'label' => 'Email',
            ),
            'attributes' => array(
                'type' => 'text',
                'class' => 'form-control col-xs-12 email',
                'placeholder' => 'Email',
            ),
        ));

        $this->add(array(
            'name' => 'display_name',
            'options' => array(
                'label' => 'Display Name',
            ),
            'attributes' => array(
                'type' => 'text',
                'class' => 'form-control col-xs-12',
                'placeholder' => 'Display Name',
            ),
        ));

        $this->add(array(
            'name' => 'password',
            'options' => array(
                'label' => 'Password',
            ),
            'attributes' => array(
                'type' => 'password',
                'class' => 'form-control col-xs-12',
            ),
        ));

        $this->add(array(
            'name' => 'passwordVerify',
            'options' => array(
                'label' => 'Password Verify',
            ),
            'attributes' => array(
                'type' => 'password',
                'class' => 'form-control col-xs-12',
            ),
        ));


        $this->add(array(
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf',
            'options' => array(
                'label' => '',
            ),
            'options' => array(
                'csrf_options' => array(
                    'timeout' => 600
                )
            )
        ));

        $submitElement = new Element\Button('submit');
        $submitElement
            ->setLabel('Submit')
            ->setAttributes(array(
                'type'  => 'submit',
                'value' => 'Register',
                'class' => 'btn btn-primary'
            ));

        $this->add($submitElement, array(
            'priority' => -100,
        ));

        $this->add(array(
            'name' => 'user_id',
            'type' => 'Zend\Form\Element\Hidden',
            'attributes' => array(
                'type' => 'hidden',
            ),
        ));
        /*
        $csrf = new Element\Csrf('csrf');
        $csrf->getValidator()->setTimeout($this->getRegistrationOptions()->getUserFormTimeout());
        $this->add($csrf);
        */
    }
}